package com.zhu.shop.goods.service.impl;

import com.zhu.shop.common.Vo.goods.GoodsVo;
import com.zhu.shop.common.Vo.Result;
import com.zhu.shop.goods.mapper.GoodsMapper;
import com.zhu.shop.goods.service.GoodsService;
import com.zhu.shop.goods.vo.Goods;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class GoodsServiceImpl  implements GoodsService {
    @Autowired
    private GoodsMapper goodsMapper;

    @Override
    public Result<GoodsVo> findGoodsById(Long id) {
        Goods goods = goodsMapper.selectById(id);
        if(null==goods){
            return Result.fail(20001,"商品不存在");
        }
        GoodsVo goodsVo=new GoodsVo();
        BeanUtils.copyProperties(goods,goodsVo);
        return Result.success(goodsVo);
    }
}
